package com.hly.tool.job;

import com.matrixone.apps.domain.Job;
import com.matrixone.apps.domain.util.FrameworkException;
import matrix.db.Context;

/**
 * Created with IntelliJ IDEA.
 * Copyright@ Apache Open Source Organization
 *
 * @Auther: HLY
 * @Date: 2022-11-08-13:39
 * @Description:
 */
public class JOBUtil
{

    /**
     * @param context
     * @param params
     * @param jpoName
     * @param methodName
     * @param action     Delete
     * @return Job
     * @Author HLY
     * @CreateTime 2022/11/8
     * @Description: 创建一个后台JOB
     */

    public static Job createAndSubmit(Context context, String[] params, String jpoName, String methodName, String action) throws FrameworkException
    {
        Job backgroundJob = new Job(jpoName, methodName, params);
        backgroundJob.setActionOnCompletion(action);
        backgroundJob.createAndSubmit(context);
        return backgroundJob;
    }


    /**
     * @param context
     * @param params
     * @param jpoName
     * @param methodName
     * @return Job
     * @Author HLY
     * @CreateTime 2022/11/8
     * @Description: 创建一个后台JOB
     */

    public static Job createAndSubmit(Context context, String[] params, String jpoName, String methodName) throws FrameworkException
    {
        Job backgroundJob = new Job(jpoName, methodName, params);
        backgroundJob.setActionOnCompletion("Delete");
        backgroundJob.createAndSubmit(context);
        return backgroundJob;
    }

}
